﻿using GetHbaseDataTests.Helpers;
using Sustainalytics.ClientDW.Entities;
using Sustainalytics.ClientDW.Synchronization.SyncHbaseData;
using Sustainalytics.ClientDW.Synchronization.SyncHbaseData.CorporateDataLogic;
using Sustainalytics.ClientDW.Synchronization.SyncHbaseData.CorporateDetailsLogic;
using System.Diagnostics;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace GetHbaseDataTests.CorporateDataLogicTests
{
    public class CorporateDataOrchestratorTests : BaseSyncHbaseTests
    {
        private readonly CorporateDataSync _sut;
        private readonly CorporateDatabaseQuery _hbaseQuery;

        public CorporateDataOrchestratorTests(ITestOutputHelper output) : base(output)
        {
            _sut = SimpleInjectorContainer.GetInstance<CorporateDataSync>();
            _hbaseQuery = SimpleInjectorContainer.GetInstance<CorporateDatabaseQuery>();
        }

        [Fact]
        public async Task Execute()
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            var corporateDetails = _hbaseQuery.Get(CorporateDetailsDataBaseQuery.Get);
            await _sut.RecreateFromCorporateDetails<CorporateData>(corporateDetails, CorporateDataCommand.RecreateIndexes);
            Log($"Duration {sw.Elapsed}");
        }
    }
}
